<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Style, DB;

class ResumeSendController extends CommonController{
    /**
     * 投递简历统计
     * @return mixed
     */
    public function sendResume(Request $request){
        $input = arrayFilter($request->only(['keyword', 'days']));
        $days = (!empty($input['days'])) ? date('Y-m-d H:i:s', strtotime('-' . $input['days'] . ' days')) : '';

        $resumeSend = DB::table('resume_send as t1')
            ->join('resume as t2', 't1.resume_id', '=', 't2.id')
            ->join('personal_users as t3', 't1.personal_uid', '=', 't3.uid')
            ->select(
                DB::raw('count(*) as countResumeSend'),
                't1.resume_id',
                't2.id', 't2.name',
                't3.uid', 't3.username', 't3.last_login_ip', 't3.last_login_time', 't3.regtime','t3.mobile'
            )
            ->where('t1.created_at', '>', $days)
            ->groupBy('t1.resume_id')
            ->orderBy('countResumeSend', 'desc')
            ->paginate(20);

        //分页分配参数 过滤boolean假值
        $appends = arrayFilter($input);
        return Style::view('admin.safety.sendResume', compact('resumeSend', 'appends'));
    }
}
